package com.huan.netty02.client;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.socket.nio.NioSocketChannel;

import java.net.InetSocketAddress;
import java.nio.charset.Charset;

/**
 * @author 作者:刘欢
 * @create 2024-03-22-17:40
 */
public class Client01 {

    Channel channel;
    //不会阻塞
    ChannelFuture future = channel.connect(            //1
            new InetSocketAddress("192.168.0.1", 25));


//        future.addListener(new ChannelFutureListener() {  //2
//        @Override
//        public void operationComplete(ChannelFuture future) {
//            if (future.isSuccess()) {                    //3
//                ByteBuf buffer = Unpooled.copiedBuffer(
//                        "Hello", Charset.defaultCharset()); //4
//                ChannelFuture wf = future.channel().writeAndFlush(buffer);                //5
//                // ...
//            } else {
//                Throwable cause = future.cause();        //6
//                cause.printStackTrace();
//            }
//        }
//    });
}
